package com.ruoyi.web.controller.shopweb;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ShopLicenceInfo;
import com.ruoyi.system.service.IShopLicenceInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营业执照信息Controller
 * 
 * @author ruoyi
 * @date 2024-06-03
 */
@RestController
@RequestMapping("/system/licence")
public class ShopLicenceInfoController extends BaseController
{
    @Autowired
    private IShopLicenceInfoService shopLicenceInfoService;

    /**
     * 查询营业执照信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopLicenceInfo shopLicenceInfo)
    {
        startPage();
        List<ShopLicenceInfo> list = shopLicenceInfoService.selectShopLicenceInfoList(shopLicenceInfo);
        return getDataTable(list);
    }

    /**
     * 导出营业执照信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "营业执照信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopLicenceInfo shopLicenceInfo)
    {
        List<ShopLicenceInfo> list = shopLicenceInfoService.selectShopLicenceInfoList(shopLicenceInfo);
        ExcelUtil<ShopLicenceInfo> util = new ExcelUtil<ShopLicenceInfo>(ShopLicenceInfo.class);
        util.exportExcel(response, list, "营业执照信息数据");
    }

    /**
     * 获取营业执照信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{licenceId}")
    public AjaxResult getInfo(@PathVariable("licenceId") Long licenceId)
    {
        return success(shopLicenceInfoService.selectShopLicenceInfoByLicenceId(licenceId));
    }

    /**
     * 新增营业执照信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "营业执照信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopLicenceInfo shopLicenceInfo)
    {
        return toAjax(shopLicenceInfoService.insertShopLicenceInfo(shopLicenceInfo));
    }

    /**
     * 修改营业执照信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "营业执照信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopLicenceInfo shopLicenceInfo)
    {
        return toAjax(shopLicenceInfoService.updateShopLicenceInfo(shopLicenceInfo));
    }

    /**
     * 删除营业执照信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "营业执照信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{licenceIds}")
    public AjaxResult remove(@PathVariable Long[] licenceIds)
    {
        return toAjax(shopLicenceInfoService.deleteShopLicenceInfoByLicenceIds(licenceIds));
    }
}
